program Treasure;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils,
  treasuremain in 'treasuremain.pas';

var
  i, t: Word;
  s: String;
begin
  try
    s := ParamStr(1);
    if (s = '') then
       s := 'input.txt';
    AssignFile(f, s);
    Reset(f);
    AssignFile(g, 'output.txt');
    Rewrite(g);
    try
      Readln(f, t);
      for i := 1 to t do begin
        verdict := '';
        EmptySpacePresent := false;
        verdictAssigned := false;
        ReadData;
        ProcessData;
        OutputVerdict(i);
      end;
    finally
      CloseFile(f);
      CloseFile(g);
    end;
    writeln('Reading finished');
    Readln;
    { TODO -oUser -cConsole Main : Insert code here }
  except
    on E: Exception do begin
      Writeln(E.ClassName, ': ', E.Message);
      readln;
    end;
  end;
end.
